<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let map2 = new Map([['a', 100], ['b', 200], ['c', 300]]);

        console.log("--1、for...of直接遍历");
        for (let obj of map2) {
            console.log(obj);
            console.log(obj[0] + "->" + obj[1]);  //0 key,1 value
        }

        console.log("--2、遍历key键");
        for (let obj of map2.keys()) {
            console.log(obj);
        }

        console.log("--3、遍历value值");
        for (let obj of map2.values()) {
            console.log(obj);
        }

        console.log("--4、遍历entries值");
        for (let obj of map2.entries()) {
            console.log(obj);
            console.log(obj[0] + "->" + obj[1]);  //0 key,1 value
        }

        console.log("--5、forEach");
        map2.forEach((v, k) => console.log(k, v));  //值在前，键在后

        console.log("--6、forEach带参数");
        map2.forEach(function (v, k) { console.log(this+k, v); }, 'Map:');  //值在前，键在后
    </script>
</body>

</html>